package com.zengge.zbc.controller;

import com.zengge.zbc.dto.Result;
import com.zengge.zbc.service.LoginService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class LoginController {

    private final LoginService loginService;

    @Autowired
    public LoginController(LoginService loginService) {
        this.loginService = loginService;
    }

    @GetMapping("/weChat/SignIn")
    @ResponseBody
    public Result<String> login(@RequestParam("code") String code) throws Exception {
        return Result.create(loginService.obtainToken(code));
    }



}
